Skip to content

stewards: wire the evidence reader into the Job-failure triage path (BB-419) - #465

Merged
trotterdylan merged 1 commit into
mainfrom
bb/bb-419-wire-evidence-reader-into-triage-path-thr_3epqnnsqsn
Dec 1, 2026
Merged

trotterdylan merged 1 commit into
mainfrom
bb/bb-419-wire-evidence-reader-into-triage-path-thr_3epqnnsqsn

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-419. The Alertmanager ops look now reads the real EvidenceReader for a firing KubeJobFailed alert in a pilot namespace and composes the three-heading reply (or the labelled "evidence unavailable" path). The occurrence is claimed before the read — the write-before-post record — so a duplicate delivery, a retry or two deliveries landing together compose at most once. The pilot is off unless the role lists ops.alertmanager.evidence; the Slack post is BB-420, so this stops at composing and recording the occurrence.

A merge to bb-plugins main moves the pin, builds a new bb-server image and stages a restart for every developer's server (.bb/AGENTS.md, "Shipping a plugin change"). It restarts in the quiet window unless someone presses Restart now.

Sibling PR: none in this repo; the Slack half is BB-420 (hooks-service endpoints plus the bb-gate tag bump). The pilot's own .bb opt-in (alertmanager.evidence) is a separate owner-reviewed change outside this repo.

Classification

owner-reviewed: the change adds evidence to the roles parsing (plugins/stewards/roles.ts, the decide list's "roles parsing" entry, decide: user) and activates the ambient-kubectl evidence read in a live path, which the decide list's access entry ("widening what an existing one can reach") makes the owner's. bb-plugins/plugins/stewards/** is otherwise project-decided. evidenceKubectlRefusal and kubectlRefusal are untouched, and no new credential, kubeconfig, RBAC, backend.json or kploy change is made.

What changes

  • config.ts / roles.ts: ops.alertmanager.evidence, the pilot namespaces whose failed-Job alerts get the reply and the only namespaces the reader may read. Empty is the off state; a role that watches Alertmanager for another namespace reads no evidence there. The legacy project.json ops path keeps it empty.
  • store.ts: a triage_occurrences table (project + occurrence key), an atomic claimTriageOccurrence (the write-before-post record) and recordTriageOccurrence. Append-only migration, hash appended to migrations.snapshot.json.
  • triage.ts: prepareTriage, the compose-only path (enabled, resolved/no-Job/no-namespace skips, the claim, the evidence read, the composer); runTriage is now this plus the Slack post. No behaviour change for the existing library.
  • server.ts: triageJobAlerts on the Alertmanager reconcile. For each firing KubeJobFailed finding in a pilot namespace it reads the Job, its pods, Warning events, logs and the recent successful Jobs with createEvidenceReader over runKubectl (the ambient identity, behind the strict allowlist), composes, and records the occurrence with posted_ts left null. Nothing calls Slack or the hooks service.
  • skills/stewards/SKILL.md: documents the new pilot field.

Testing

  • plugins/stewards: npm run typecheck pass; npm test pass (62 files, 2616 tests; the plugin is not in the CI matrix).
  • server.test.ts (new): a KubeJobFailed alert in a pilot namespace composes the three headings from a fake kubectl and records the occurrence once; a repeated firing reads no evidence a second time; an empty pilot list reads nothing and leaves the Alertmanager watch unchanged; a forbidden log read is labelled "could not be read" and still composes.
  • triage.test.ts: prepareTriage composes without a replier and claims once; resolved and non-Job alerts skip without claiming.
  • store.test.ts: the claim is durable (a second claim is false), the composed text and posted_ts are stored separately, and each project's occurrence is its own.
  • config.test.ts: the pilot parses on the definition and the effective role, defaults off, and refuses a bad namespace.
  • Not tested end to end: the Slack post, which is not built (BB-420), and the live cluster read, which needs the pilot .bb opt-in and the owner's server.

…BB-419)

The Alertmanager ops look now reads the real evidence reader for a firing
KubeJobFailed alert in a pilot namespace and composes the three-heading reply
(or the labelled "evidence unavailable" path). The occurrence is claimed
before the read (the write-before-post record), so a duplicate delivery
composes at most once. The pilot is off unless the role lists an
`ops.alertmanager.evidence` namespace; the Slack post is BB-420, so this stops
at composing and recording the occurrence.

- roles/config: `alertmanager.evidence`, the pilot namespaces; empty is off.
- store: a `triage_occurrences` table and the atomic claim.
- server: `triageJobAlerts` on the Alertmanager reconcile, with the ambient
  kubectl behind the untouched `evidenceKubectlRefusal`.
- triage: `prepareTriage`, the compose-only path `runTriage` is built on.
- tests: fakes for the reader and kubectl.

No Slack or hooks endpoint is called. No credential, kubeconfig, RBAC,
backend.json or kploy change, and `evidenceKubectlRefusal` is untouched.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_pfmfbsmd8w.

— from bb thread thr_3epqnnsqsn

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM-5.3, at ec328f2)

Owner review required: yes — the diff adds a key to the roles parsing (plugins/stewards/roles.ts, config.ts), which the decide list's "The stewards plugin's roles parsing, ready gate and escalation routing" entry makes the owner's, and it activates the ambient-kubectl evidence read in a live path, which the "widening what an existing one can reach" entry also makes the owner's. @trotterdylan, this one needs your approval, and the escalation is binding: a project-steward approval will not meet the gate.

Product

The change turns the merged-but-uncalled triage library (#461, #464) into a live background path: each Alertmanager look now composes the three-heading reply for a firing KubeJobFailed alert in a pilot namespace, claims the occurrence before the evidence read, and records the composed text with posted_ts null for BB-420. I searched plugins/stewards/DESIGN.md, skills/stewards/SKILL.md and the code (triage, KubeJobFailed, evidence) for existing coverage of the need: nothing else composes or records this reply — before this PR createEvidenceReader had no caller — so there is no overlap. The scope matches the wiring slice asked: no Slack or hooks call, evidenceKubectlRefusal untouched, source-contract.ts and the gate files untouched, no credential/RBAC/backend.json/kploy change, and the pilot is off unless a role lists ops.alertmanager.evidence (the legacy project.json path stays off). The append-only migration, the atomic INSERT OR IGNORE claim and the error-scrubbed, per-finding catch in server.ts all read correct; a server restart between claim and compose loses one triage rather than duplicating it, which is the write-before-post design the approved spec names.

Tested

  • Ran: npm run typecheck (pass) and the touched suites locally — server.test.ts (1110 tests, including the four new BB-419 ones), triage.test.ts, store.test.ts, config.test.ts, migrations.test.ts — all pass; CI's stewards job ran the full suite green at this head.
  • Not exercised: the live cluster read, which needs the pilot .bb opt-in (a separate owner-reviewed change) on the owner's server; and the Slack post, which is BB-420 and is not built here.

Looks good.

— from bb thread thr_pfmfbsmd8w

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved ec328f2 from the Stewards page

@trotterdylan
trotterdylan merged commit 6336fb7 into main Dec 1, 2026
25 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-419-wire-evidence-reader-into-triage-path-thr_3epqnnsqsn branch December 1, 2026 18:58
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved ec328f2, checks green, approved by the owner, escalated by the reviewer to the owner.
merge commit 6336fb7
Note: merging this moves the pin and stages a restart for every developer's server (Restart now, or in the 03:00–05:00 ET quiet window).
dispatched bb-server.yaml on bitcomplete/bb-gate@main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant